<?php

use Hyperf\Database\Schema\Schema;
use Hyperf\Database\Schema\Blueprint;
use Hyperf\Database\Migrations\Migration;

class CreatTableContentItem extends Migration
{
    /**
     * Run the migrations.
     */
    public function up(): void
    {
        Schema::create('content_item', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->tinyInteger('type_id', false, true)->default(0)->comment('类型:0文章/1图片Banner/2文字链接');
            $table->integer('menu_id', false, true)->default(0)->comment('栏目ID');
            $table->integer('main_id', false, true)->default(0)->comment('主ID');
            $table->integer('page_number', false, true)->default(0)->comment('页号,越小越前');
            $table->integer('top_number', false, true)->default(0)->comment('置顶');
            $table->integer('sort_number', false, true)->default(0)->comment('排序,越大越前');
            $table->tinyInteger('status', false, true)->default(0)->comment('状态');
            $table->integer('viewed_count', false, true)->default(0)->comment('查看统计');
            $table->integer('liked_count', false, true)->default(0)->comment('点赞统计');
            $table->string('tag_ids', 255)->default('')->comment('以逗号隔开的id');
            $table->string('title', 255)->default('')->comment('标题');
            $table->string('title_short', 255)->default('')->comment('副标题');
            $table->string('source_from', 255)->default('')->comment('来源');
            $table->string('image_cover', 255)->default('')->comment('封面图');
            $table->string('image_inner', 255)->default('')->comment('内图');
            $table->string('image_link', 255)->default('')->comment('图片链接');
            $table->tinyInteger('content_ide', false, true)->default(0)->comment('内容编辑IDE');
            $table->text('content_short')->nullable(true)->comment('内容截取');
            $table->longText('content')->nullable(true)->comment('内容主体');
            $table->timestamp('enable_start', 0)->nullable(true)->comment('可用开始时间');
            $table->timestamp('enable_end', 0)->nullable(true)->comment('可用结束时间');
            $table->timestamps();
            $table->softDeletes();
            $table->index('type_id', 'index_type_id');
            $table->index('menu_id', 'index_menu_id');
            $table->index('main_id', 'index_main_id');
            $table->index('status', 'index_status');
        });
    }

    /**
     * Reverse the migrations.
     */
    public function down(): void
    {
        Schema::dropIfExists('content_item');
    }
}
